"""
Views that return JSON pages.
"""

from django.contrib.auth.decorators import login_required
from django.utils import simplejson as json
from django.http import HttpResponse

from map.models import Service

@login_required
def services(request):
  """Obtain list of available mapping services"""
  response = HttpResponse(mimetype='application/json')
  
  response.write(json.dumps([{
    'name': service.name
    } for service in Service.objects.all()]))
  
  return response
